﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using CTEM.ModuleForms.ManageEmployee;
using System.Collections.Generic;
using CTEM.Models;

namespace CTEM.ModuleForms.ManageReport
{
    public partial class xtra_EmployeeSalaryReport : DevExpress.XtraReports.UI.XtraReport
    {
        public xtra_EmployeeSalaryReport()
        {
            InitializeComponent();
        }
        public void DataBind(List<EmployeeSalaryDTO> listEmployeeSalary, DateTime fromTime, DateTime toTime, EmployerDTO employee)
        {
            lFromDay.Text = fromTime.ToString("MM/yyyy");
            lToday.Text = toTime.ToString("MM/yyyy");
            lTotalDebt.Text = employee.totalDebt.ToString("n0");
            lName.Text = employee.Fullname;
            foreach (var emp in listEmployeeSalary)
	        {
                XRTableRow rowtitle = new XRTableRow();
                rowtitle.Name = "row 1";
                rowtitle.WidthF = 830;
                rowtitle.HeightF = 30;
                // month

                emp.Month = emp.MonthFormat.ToString("MM/yyyy");  
                XRTableCell clmonth = new XRTableCell();

                clmonth.Name = "clName";
                clmonth.Text = Convert.ToString(emp.Month);
                clmonth.WidthF = 90;
                clmonth.HeightF = 30;
                rowtitle.Cells.Add(clmonth);

                // salary
                XRTableCell clSalary = new XRTableCell();
                clSalary.Name = "clSalary";
                clSalary.Text = emp.Salary.ToString("n0");
                clSalary.WidthF = 95;
                clSalary.HeightF = 30;
                rowtitle.Cells.Add(clSalary);

                // TotalAllowance
                XRTableCell clTotalAllowance = new XRTableCell();
                clTotalAllowance.Name = "clTotalAllowance";
                clTotalAllowance.Text = emp.TotalAllowance.ToString("n0");
                clTotalAllowance.WidthF = 95;
                clTotalAllowance.HeightF = 30;
                rowtitle.Cells.Add(clTotalAllowance);

                // DebtPay
                XRTableCell clSDebtPay = new XRTableCell();
                clSDebtPay.Name = "clDebtPay";
                clSDebtPay.Text = emp.DebtPay.ToString("n0");
                clSDebtPay.WidthF = 95;
                clSDebtPay.HeightF = 30;
                rowtitle.Cells.Add(clSDebtPay);


                 // Debt1
                XRTableCell clSDebt1 = new XRTableCell();
                clSDebt1.Name = "clDebt1";
                clSDebt1.Text = emp.Debt1.ToString("n0");
                clSDebt1.WidthF = 90;
                clSDebt1.HeightF = 30;
                rowtitle.Cells.Add(clSDebt1);

                 // Debt1
                XRTableCell clSDebt2 = new XRTableCell();
                clSDebt2.Name = "clDebt1";
                clSDebt2.Text = emp.Debt2.ToString("n0");
                clSDebt2.WidthF = 90;
                clSDebt2.HeightF = 30;
                rowtitle.Cells.Add(clSDebt2);

                 //TotalAdvanceSalary

                XRTableCell clTotalAdvanceSalary = new XRTableCell();
                clTotalAdvanceSalary.Name = "clTotalAdvanceSalary";
                clTotalAdvanceSalary.Text = emp.TotalAdvanceSalary.ToString("n0");
                clTotalAdvanceSalary.WidthF = 95;
                clTotalAdvanceSalary.HeightF = 30;
                rowtitle.Cells.Add(clTotalAdvanceSalary);

                //ActualIncome

                XRTableCell clActualIncome = new XRTableCell();
                clActualIncome.Name = "clActualIncome";
                clActualIncome.Text = emp.ActualIncome.ToString("n0");
                clActualIncome.WidthF = 95;
                clActualIncome.HeightF = 30;
                rowtitle.Cells.Add(clActualIncome);

                 //GenerateDebt

                XRTableCell clGenerateDebt = new XRTableCell();
                clGenerateDebt.Name = "clGenerateDebt";
                clGenerateDebt.Text = emp.GenDebt.ToString("n0");
                clGenerateDebt.WidthF = 95;
                clGenerateDebt.HeightF = 30;
                rowtitle.Cells.Add(clGenerateDebt);

                xrTable1.Rows.Add(rowtitle);
            }

        }
    }
}
